package com.iman.Confucius.service.impl.teacher;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.inject.Inject;

import org.springframework.stereotype.Service;

import com.iman.Confucius.service.teacher.CareerPlanService;
import com.iman.Confucius.vo.student.StudentVo;
import com.iman.common.hibernate.TemplateQLService;

@Service
public class CareerPlanServiceImpl implements CareerPlanService {
	@Inject
    private TemplateQLService templateQLService;
	
	@Override
	public List<StudentVo> unplanStudents(Long teacherid) {
		Map<String,Object> params = new HashMap<String,Object>();
		params.put("teacher_id",teacherid);
		List<StudentVo> list = this.templateQLService.findBySQLBeanQuery("teac-unplan-students", params, StudentVo.class);
		return list;
	}

	@Override
	public void saveCareerPlan(Map<String, Object> params) {
		Object o = this.templateQLService.executeSQLUpdate("teac-save-career-plan", params);
		//System.out.println(o);
	}

	@Override
	public List<Map> planedStudents(Map<String,Object> params) {		
		return this.templateQLService.findBySQLMapQuery("teac-planned-students", params);
	}

	@Override
	public List<Map> planedStudentsPlanings(Map<String,Object> params) {
		return this.templateQLService.findBySQLMapQuery("teac-planned-plannings", params);
	}

	@Override
	public List<Map> myPlannings(Long studentid) {
		Map<String,Object> params = new HashMap<String,Object>();
		params.put("student_id",studentid);
		return this.templateQLService.findBySQLMapQuery("stud-plannings", params);
	}

	@Override
	public void deleteCareerPlan(long careerid) {
		Map<String,Object> params = new HashMap<String,Object>();
		params.put("id",careerid);
		this.templateQLService.executeSQLUpdate("teac-delete-career", params);
	}

	@Override
	public void downloadCarrer(long careerid) {
		Map<String,Object> params = new HashMap<String,Object>();
		params.put("id",careerid);
		params.put("update_time", new Date());
		this.templateQLService.executeSQLUpdate("teac-incr-download-career", params);	
	}

}
